<script>
	import config from './config'
	import store from '@/store'
	import {
		getToken
	} from '@/utils/auth'

	export default {
		onLaunch: function() {
			this.initApp()

		},
		onReady() {
			this.getSysteminfo()
		},
		methods: {
			// 获取系统栏高度
			getSysteminfo() {
				uni.getSystemInfo({
					success: res => {
						this.globalData.systemBarHeight = res.statusBarHeight;
						this.globalData.windowWidth = res.windowWidth
					}
				});
			},
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				// 检查用户登录状态
				//#ifdef H5
				this.checkLogin()
				//#endif
			},
			initConfig() {
				// 获取胶囊按钮信息
				let menuInfo = uni.getMenuButtonBoundingClientRect()
				// 胶囊高度
				this.globalData.menuHeight = menuInfo.height
				// 顶部功能栏高度 = 胶囊按钮高度 + 距离顶部高度 + 设定底部距离
				this.globalData.menuBarHeight = menuInfo.height + menuInfo.top + 10
				// 顶部功能栏右边距 = 屏幕宽度 - 胶囊左边界到页面可视范围的左边界
				this.globalData.menuBarRight = this.globalData.windowWidth - menuInfo.left
				this.globalData.config = config
			},
			checkLogin() {
				if (!getToken()) {
					this.$tab.reLaunch('/pages/login')
				}
			}
		}
	}
</script>

<style>
	@import '@/wxcomponents/vant-weapp/dist/common/index.wxss';
</style>
<style lang="scss">
	@import '@/static/scss/index.scss';
	@import '@/uni_modules/uview-ui/index.scss';

	.u-form-item__body__right__message {
		text-align: right;
	}

	.uni-select {
		text-align: right;
		border: none;
	}

	page {
		padding-bottom: 20px;
	}

	::v-deep .van-button {
		width: 100%;
	}
</style>